﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using System.Configuration;
using Microsoft.ReportingServices;
using Microsoft.Reporting.WinForms;

namespace CimeaSoft.UI.Reportes
{
    public partial class FrmReporteMuestra : Form
    {

        public int IdMuestra;

        public FrmReporteMuestra()
        {
            InitializeComponent();
        }

        private void FrmReporteMuestra_Load(object sender, EventArgs e)
        {
            var user = ConfigurationManager.AppSettings.Get("userReport");
            var pws = ConfigurationManager.AppSettings.Get("pwsReport");
            reportViewer1.ServerReport.ReportServerCredentials.NetworkCredentials = new NetworkCredential(user,pws);

            var ipServer = ConfigurationManager.AppSettings.Get("ipServer");
            var path = ConfigurationManager.AppSettings.Get("path");
            reportViewer1.ProcessingMode = ProcessingMode.Remote;
            reportViewer1.ServerReport.ReportPath=path;
            reportViewer1.ServerReport.ReportServerUrl=new Uri(ipServer,System.UriKind.Absolute);

            ReportParameter[] parameters = new ReportParameter[1];
            parameters[0] = new ReportParameter("Id",IdMuestra.ToString());

            reportViewer1.ServerReport.SetParameters(parameters);
            this.reportViewer1.RefreshReport();
        }

        public int ObtenerId(int id)
        {
            IdMuestra = id;
            return IdMuestra;
        }
    }
}
